﻿using QFramework;
using UnityEngine;
using Object = UnityEngine.Object;

namespace Gp.Scripts.Core
{
    public abstract class BaseGameManager : ISystem, IStructure
    {
        protected abstract void OnInit();

        public void Init()
        {
            Debug.Log("Loading Game Manager: " + GetType().Name);
            CommonUtils.SafeCall(OnInit, "BaseGameManager", "在载入 {typeof(T).FullName} 时出现了异常。");
        }
        
        public IArchitecture GetArchitecture() => MainArchitecture.Interface;
        public void SetArchitecture(IArchitecture architecture) { }

        
        public virtual void OnUpdate() { }


        protected void Log(string msg, Object context = null)
        {
            Debug.Log($"[{GetType().Name}]: {msg}", context);
        }

        protected void LogError(string msg, Object context = null)
        {
            Debug.LogError($"[{GetType().Name}]: {msg}", context);
        }
    }
}